home *** CD-ROM | disk | FTP | other *** search
/ PC Gamer (Italian) 30 / PC Gamer IT CD 30 1-2.iso / MOTS / GAMEDATA / RESOURCE / JKMRES.GOO / cog_pow_single_flashbomb_m.cog < prev    next >
Text File  |  1998-02-25  |  5KB  |  179 lines

  1. # Jedi Knight Missions Cog Script
  2. #
  3. # POW_SINGLE_FLASHBOMB_M.COG
  4. #
  5. # POWERUP Script - single Flash Bomb
  6. #
  7. # [YB & CYW] + [RF]
  8. #
  9. # (C) 1997 LucasArts Entertainment Co. All Rights Reserved
  10.  
  11.  
  12. symbols
  13.  
  14. template    explode=+flash_exp              local
  15.  
  16. thing       powerup                          local
  17. thing       player                           local
  18. thing       sender                           local
  19.  
  20. int         bin=14                           local
  21. sound       pickupsnd=thrmlpu2.wav           local
  22. sound       respawnsnd=Activate01.wav        local
  23. flex        amount                           local
  24.  
  25. #for the projectiles
  26. vector      dir                              local
  27.  
  28. int         autosel=-1                       local
  29. int         bin_contents=0                   local
  30. int         autopickup=0                     local
  31.  
  32. message     created
  33. message     damaged
  34. message     touched
  35. message     taken
  36. message     respawn
  37. message     timer
  38.  
  39. end
  40.  
  41. # ========================================================================================
  42.  
  43. code
  44.  
  45. created:
  46.    SetThingUserData(GetSenderRef(), 30);     // set the initial user data (i.e. "health")
  47.    Return;
  48.  
  49. # ............................................................................................
  50.  
  51. touched:
  52.    if (GetWeaponBin(bin) == -1)
  53.       return;
  54.  
  55.    player = GetSourceRef();
  56.    if (GetThingType(player) == 10)  // Can only be taken by players.
  57.    {
  58.       amount = GetInv(player, GetWeaponBin(bin));
  59.  
  60.       if (IsMulti() || (amount < GetInvMax(player, GetWeaponBin(bin))))
  61.       {
  62.          TakeItem(GetSenderRef(), -1);
  63.          call taken;
  64.       }
  65.    }
  66.  
  67.    Return;
  68.  
  69. # ........................................................................................
  70.  
  71. damaged:
  72.    damage = GetParam (0);
  73.    sender = GetSenderRef();
  74.  
  75.    // only take damage 33% of the time
  76.    if(rand() < 0.33)
  77.       return;
  78.  
  79.    // If it's already dead, don't allow any more damage.
  80.    if (!GetThingUserData (sender))
  81.       return;
  82.  
  83.    // see if this will cause the explosion
  84.    if (GetThingUserData (sender) <= damage)
  85.    {
  86.       SetThingUserData (sender, 0);
  87.  
  88.       // timer for base explosion
  89.       SetTimerEx ((Rand () * 0.5), sender, 1, 0);
  90.    }
  91.    else
  92.    {
  93.       SetThingUserData (sender, GetThingUserData (sender) - damage);
  94.    }
  95.  
  96.    ReturnEx (0);
  97.    return;
  98.  
  99. # ........................................................................................
  100.  
  101. taken:
  102.    if (GetWeaponBin(bin) == -1)
  103.       return;
  104.  
  105.    player = GetSourceRef();
  106.    powerup = GetSenderRef();
  107.  
  108. // // If the object has been destroyed, don't award it to the player.
  109. //   if (!GetThingUserData (powerup))
  110. //    return;
  111.  
  112.    // Print("Thermal Detonator");
  113.    jkPrintUNIString(player, 211);
  114.  
  115.    // Do effects.
  116.    PlaySoundLocal(pickupsnd, 1, 0, 0);
  117.    AddDynamicTint(player, 0.0, 0.0, 0.2);
  118.  
  119.    // store the old bin contents
  120.    bin_contents = GetInv(player, GetWeaponBin(bin));
  121.  
  122.    // Increment powerup amount.
  123.    ChangeInv(player, GetWeaponBin(bin), 1.0);
  124.  
  125.    // Check for Auto Pickup
  126.    autopickup = GetAutoPickup();
  127.    if((autopickup & 1) && !(autopickup & 2)) // DANGEROUS
  128.    {
  129.       if(!bin_contents)
  130.       {
  131.          if(!((autopickup & 4) && (GetWeaponPriority(player, GetWeaponBin(GetCurWeapon(player)), 0) >= GetWeaponPriority(player, bin, 0))))
  132.          {
  133.             if(!((autopickup & 8) && (GetWeaponBin(GetCurWeapon(player)) == jkGetMultiParam(1))))
  134.             {
  135.                SelectWeapon(player, GetWeaponBin(bin));
  136.                Return;
  137.             }
  138.          }
  139.       }
  140.    }
  141.  
  142.    // Check for Auto Reload
  143.    if(GetAutoReload() & 1)
  144.    {
  145.       if(!bin_contents)
  146.       {
  147.          if(!((GetAutoReload() & 2) && (GetWeaponBin(GetCurWeapon(player)) == jkGetMultiParam(1))))
  148.          {
  149.             // Try to autoselect and see if the best weapon is the TD
  150.             autosel = AutoSelectWeapon(player, 2);
  151.             if(autosel == bin) SelectWeapon(player, GetWeaponBin(bin));
  152.          }
  153.       }
  154.    }
  155.  
  156.    return;
  157.  
  158. # ........................................................................................
  159.  
  160. respawn:
  161.    SetThingUserData(GetSenderRef(), 30);     // set the initial user data (i.e. "health")
  162.    PlaySoundThingLocal(respawnsnd, GetSenderRef(), 0.6, 5.0, 10.0, 0);
  163.  
  164.    return;
  165.  
  166. # ........................................................................................
  167.  
  168. timer:
  169.    sender = GetSenderId ();
  170.  
  171.    // cause the base explosion
  172.    powerup = CreateThingNR(explode, sender);
  173.  
  174.    // Since the user data is 0, the player won't actually be awarded this powerup.
  175.    TakeItem (sender, -1);
  176.    return;
  177.  
  178. end
  179.